﻿using CleanArchitecture.Core.Interfaces;
using CleanArchitecture.Infrastructure.Entities.Business;
using System;
using System.Collections.Generic;

namespace CleanArchitecture.Infrastructure.Interfaces.Business
{
    public partial interface INewsService
    {
        #region News

        /// <summary>
        /// Deletes a news Batch
        /// </summary>
        /// <param name="newsItems">News item List</param>
        /// <param name="logEvent">Whether to log Delete Event</param>
        void DeleteNewsBatch(IList<NewsItem> newsItems, bool logEvent = true);

        /// <summary>
        /// Gets a news
        /// </summary>
        /// <param name="newsId">The news identifier</param>
        /// <param name="showContents">增加是否对获取文章内容的获取</param>
        /// <returns>News</returns>
        NewsItem GetNewsItemById(int newsId, bool showContents = true);
        /// <summary>
        /// 根据当前文章ID获取同栏目上一篇文章及下一篇文章
        /// </summary>
        /// <param name="curNewsId"></param>
        /// <param name="curColumnId"></param>
        /// <returns></returns>
        (NewsItem, NewsItem) GetPrivateandNextNewsItems(int curNewsId, int curColumnId = 0);
        /// <summary>
        /// Gets all news 
        /// DavidLee 2019/11/28 
        /// 在新闻列表加载时只加载部分信息，不全量加载，文章内容为html文本内容，全量加载会很慢
        /// 只有在编辑文章时才全量加载指定文章所有内容,所以在实现时只返回linq列表，不要ToList去执行SQL查询
        /// </summary>
        /// <param name="pageIndex">Page index</param>
        /// <param name="pageSize">Page size</param>
        /// <returns>News items</returns>
        IViewPagedList<NewsItem> GetNewsItemsByPage(int columnId = 0, int[] roleIds = null, int pageIndex = 0, int pageSize = int.MaxValue);
        /// <summary>
        /// 根据栏目Id获取栏目下对应的文章
        /// 适用于栏目为单页内容展示
        /// </summary>
        /// <param name="columnId"></param>
        /// <returns></returns>
        NewsItem GetNewsItemByColumnId(int columnId);

        /// <summary>
        /// Gets top N news by Column Id
        /// </summary>
        /// <param name="newsId">The news identifiers</param>
        /// <param name="columnId">columnId that newsitem belongs with</param>
        /// <param name="excludeIds">the results items without exludeIds</param>
        /// <returns>News</returns>
        IList<NewsItem> GetNewsItemListByColumnId(int columnId, int topN = 1, int[] excludeIds = null);
        /// <summary>
        /// 获取每个栏目下推荐/置顶的前N条文章/新闻
        /// </summary>
        /// <param name="columnIds"></param>
        /// <param name="topN"></param>
        /// <returns></returns>
        IList<NewsItem> GetRecommendNewsItemsByColumnIds(int[] columnIds, int topN = 1);
        /// <summary>
        /// 根据栏目菜单Id获取每个栏目下前N条文章信息
        /// </summary>
        /// <param name="columnIds">Arrays of Column Id</param>
        /// <param name="topN">Number of NewsItem of each group column, Default: 1</param>
        /// <returns></returns>
        IList<NewsItem> GetNewsItemsByColumnIds(int[] columnIds, int topN = 1);
        /// <summary>
        /// 统计新闻/文章总数
        /// </summary>
        /// <returns></returns>
        int StatisticsNewsCount();
        /// <summary>
        /// Inserts a news item
        /// </summary>
        /// <param name="news">News item</param>
        void InsertNews(NewsItem news);

        /// <summary>
        /// Updates the news item
        /// </summary>
        /// <param name="news">News item</param>
        void UpdateNews(NewsItem news);

        /// <summary>
        /// Get a value indicating whether a news item is available now (availability dates)
        /// </summary>
        /// <param name="newsItem">News item</param>
        /// <param name="dateTime">Datetime to check; pass null to use current date</param>
        /// <returns>Result</returns>
        bool IsNewsAvailable(NewsItem newsItem, DateTime? dateTime = null);

        #endregion

        #region News comments

        ///// <summary>
        ///// Gets all comments
        ///// </summary>
        ///// <param name="customerId">Customer identifier; 0 to load all records</param>
        ///// <param name="storeId">Store identifier; pass 0 to load all records</param>
        ///// <param name="newsItemId">News item ID; 0 or null to load all records</param>
        ///// <param name="approved">A value indicating whether to content is approved; null to load all records</param> 
        ///// <param name="fromUtc">Item creation from; null to load all records</param>
        ///// <param name="toUtc">Item creation to; null to load all records</param>
        ///// <param name="commentText">Search comment text; null to load all records</param>
        ///// <returns>Comments</returns>
        //IList<NewsComment> GetAllComments(int customerId = 0, int storeId = 0, int? newsItemId = null,
        //    bool? approved = null, DateTime? fromUtc = null, DateTime? toUtc = null, string commentText = null);

        ///// <summary>
        ///// Gets a news comment
        ///// </summary>
        ///// <param name="newsCommentId">News comment identifier</param>
        ///// <returns>News comment</returns>
        //NewsComment GetNewsCommentById(int newsCommentId);

        ///// <summary>
        ///// Get news comments by identifiers
        ///// </summary>
        ///// <param name="commentIds">News comment identifiers</param>
        ///// <returns>News comments</returns>
        //IList<NewsComment> GetNewsCommentsByIds(int[] commentIds);

        ///// <summary>
        ///// Get the count of news comments
        ///// </summary>
        ///// <param name="newsItem">News item</param>
        ///// <param name="storeId">Store identifier; pass 0 to load all records</param>
        ///// <param name="isApproved">A value indicating whether to count only approved or not approved comments; pass null to get number of all comments</param>
        ///// <returns>Number of news comments</returns>
        //int GetNewsCommentsCount(NewsItem newsItem, int storeId = 0, bool? isApproved = null);

        ///// <summary>
        ///// Deletes a news comment
        ///// </summary>
        ///// <param name="newsComment">News comment</param>
        //void DeleteNewsComment(NewsComment newsComment);

        ///// <summary>
        ///// Deletes a news comments
        ///// </summary>
        ///// <param name="newsComments">News comments</param>
        //void DeleteNewsComments(IList<NewsComment> newsComments);

        #endregion
    }
}
